package com.sakura.probe.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.sakura.probe.common.api.CommonResult;
import com.sakura.probe.common.api.Page;
import com.sakura.probe.common.util.PageCalculate;
import com.sakura.probe.mapper.FeedBackMapper;
import com.sakura.probe.pojo.FeedBack;
import com.sakura.probe.service.FeedBackService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.List;

@Service
public class FeedBackServiceImpl extends ServiceImpl<FeedBackMapper, FeedBack> implements FeedBackService {

    @Autowired
    private FeedBackMapper feedBackMapper;

    @Override
    public Page<FeedBack> getListByCondition(FeedBack condition, int pageIndex, int pageSize) {

        List<FeedBack> records = feedBackMapper.queryFeedBackList(condition, PageCalculate.calculateRowIndex(pageIndex, pageSize),
                pageSize);
        Long total = feedBackMapper.queryFeedBackCount(condition);
        Long pages = total%pageSize==0?total/pageSize:(total/pageSize+1);
        Page<FeedBack> page = new Page<>(records,total,pages);
        return page;
    }
}
